<template>
    <div class="app-container">
        <!-- 查询模块 -->
        <div class="formDiv">
            <el-form ref="form"  :inline="true" label-width="140px">
                <el-row>
                    <!-- <el-col :span="6">
                        <el-form-item label="姓名">
                        <el-input v-model="params.legalName" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="证件号码">
                        <el-input v-model="params.identityCode" />
                        </el-form-item>
                    </el-col>-->
                    <el-col :span="6">
                        <el-form-item label="医院名称">
                            <hospitalListbth :type="1" @childfun="childfun" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="开户时间">
                            <el-date-picker
                                type="daterange"
                                value-format="yyyy-MM-dd HH:mm:ss"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                v-model="time"
                                :default-time="['00:00:00', '23:59:59']"
                            ></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="6">
                        <el-form-item label="开户状态">
                            <el-select filterable v-model="params.accountOpenStatus" placeholder="请选择">
                                <el-option
                                    v-for="item in accStatus"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> -->
                    <el-col :span="6">
                        <el-button style="margin-left:60px" type="primary" @click="searchfun">查询</el-button>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <!-- 主页列表 -->
        <div class="listDiv" v-loading="loadings">
            <!-- table列表 -->
            <el-table :data="tableData" class="tableData" style="width: 100%">
                <el-table-column
                    type="index"
                    label="序号"
                    fixed="left"
                    align="center"
                    :index="table_index"
                    width="50"
                ></el-table-column>
                <!-- <el-table-column prop="contactsName" label="姓名" align="center" /> -->
                <el-table-column prop="subMerType" label="商户类型" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.subMerType==1">个人</span>
                        <span v-if="scope.row.subMerType==2">个体</span>
                        <span v-if="scope.row.subMerType==3">企业商户</span>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="医院名称" align="center" />
                <el-table-column prop="subMerName" label="商户名称" align="center" />
                <el-table-column prop="legalName" label="企业法人" align="center" />
                <el-table-column prop="identityId" label="身份证" align="center" />
                <el-table-column label="证件号码" align="center">
                    <template slot-scope="scope">
                        <span
                            v-if="scope.row.certType==1 || scope.row.certType==2"
                        >{{scope.row.certId}}</span>
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="bankBranchName" label="银行卡开户行" align="center" /> -->
                <!-- <el-table-column prop="bankAccount" label="银行卡号" align="center" /> -->
                <el-table-column prop="certType" label="证件类型" align="center">
                    <template slot-scope="scope">
                        <span v-if="scope.row.certType==1">营业执照</span>
                        <span v-if="scope.row.certType==2">统一社会信用代码</span>
                    </template>
                </el-table-column>
                <el-table-column prop="userId" label="第三方开户编码" align="center" />
                <el-table-column prop="accountOpenStatus" label="开户状态" align="center">
                    <template slot-scope="scope">{{scope.row.accountOpenStatus | accStatusType}}</template>
                </el-table-column>
                <el-table-column prop="opeTime" label="开户时间" align="center" />
            </el-table>

            <!-- 分页 -->
            <div class="pagesCon">
                <div>
                    <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="params.pageNum"
                        :page-sizes="[10, 20, 50, 100]"
                        :page-size="params.pageSize"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total"
                    ></el-pagination>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
import { list } from "@/api/mangeHospital/mangelist";
import hospitalListbth from "@/components/hospitalList";
export default {
    name: "mangelist",
    components: {
        hospitalListbth
    },
    data() {
        return {
            loadings: true,
            tableData: [],
            total: 0,
            time: "",
            params: {
                targetId: "",
                pageNum: 1,
                // legalName: "",
                // identityCode: "",
                openStartime: "",
                openEndtime: "",
                // accountOpenStatus:-1,
                pageSize: 10
            },
            // 开户状态
            // accStatus: [
            //     {
            //         value: -1,
            //         label: "全部"
            //     },
            //     {
            //         value: 0,
            //         label: "未开户"
            //     },
            //     {
            //         value: 1,
            //         label: "待审核"
            //     },
            //     {
            //         value: 2,
            //         label: "开户成功"
            //     },
            //     {
            //         value: 3,
            //         label: "开户失败"
            //     }
            // ]
        };
    },
    filters: {
        accStatusType(e) {
            switch (e) {
                case 0:
                    return "未开户";
                case 1:
                    return "待审核";
                case 2:
                    return "开户成功";
                case 3:
                    return "开户失败";
            }
        }
    },
    watch: {
        time(val) {
            this.params.openStartime = val ? val[0] : "";
            this.params.openEndtime = val ? val[1] : "";
        }
    },
    mounted() {
        this.listfun();
    },
    methods: {
        searchfun() {
            this.params.pageNum = 1;
            this.listfun();
        },
        listfun() {
            this.loadings = true;
            list(this.params).then(res => {
                // console.log(res);
                if (res.data.code == 0) {
                    this.tableData = res.data.data.list;
                    this.total = res.data.data.count;
                } else {
                    this.$message.error(res.data.msg);
                }
                this.loadings = false;
            });
        },
        childfun(res) {
            this.params.targetId = res.id + "";
        },
        handleSizeChange(val) {
            this.params.pageNum = 1;
            this.params.pageSize = val;
            this.listfun();
        },
        handleCurrentChange(val) {
            this.params.pageNum = val;
            this.listfun();
        },
        table_index(index) {
            return (this.params.pageNum - 1) * this.params.pageSize + index + 1;
        }
    }
};
</script>
<style scoped>
/* 分页 */
.pagesCon {
    height: 40px;
    margin-top: 20px;
}
.pagesCon > div {
    float: right;
}
/* 表单样式修改 */
.el-range-editor--medium.el-input__inner {
    width: 236px;
}
</style>